﻿using System;
using System.Data;
using System.Text.RegularExpressions;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

/// <summary>
/// Summary description for FrontPageAdmin
/// </summary>
public class FrontPageAdmin
{
	public FrontPageAdmin()
	{
        
	}
    public static string CreateFrontPage(string Titel, string Type, string Tekst, string ID)
    {
        if (ID.Length == 3) ID = "0" + ID;
        if (ID.Length == 2) ID = "00" + ID;
        if (ID.Length == 1) ID = "000" + ID;
        string Link;
        Link = Regex.Replace(Titel, " ", "-");
        Link = Regex.Replace(Titel, ":", "");
        Link = Regex.Replace(Titel, "&", "and");
        //Link = Regex.Replace(Titel, "?", "-");

        if (Type == "nyhed")
        {
            Link = ID + "-" + Titel + "-nyhed.aspx";
        }
        else
        {
            Link = ID + "-" + Titel + "-anmeldelse.aspx";
        }

        ReviewerMySql SQL = new ReviewerMySql();
        SQL.ExecuteNonQuery("INSERT INTO V2_ForsidePost(Titel, ForsideType, Tekst, Link, Dato, Aktiv) VALUES('" + Titel + "','" + Type + "','" + Tekst + "','" + Link + "','" + DateTime.Now.ToShortDateString() + "','False')");
        return "INSERT INTO V2_ForsidePost(Titel, ForsideType, Tekst, Link, Dato, Aktiv) VALUES('" + Titel + "','" + Type + "','" + Tekst + "','" + Link + "','" + DateTime.Now.ToShortDateString() + "','False')";
    }
}
